function isf = istransio(htio, varargin)
% istransio  - check (and validate) object
%
% FORMAT:       isf = istransio(hfile [, valid])
%
% Input fields:
%
%       hfile       MxN argument check for class
%       valid       if given and true, perform validation
%
% Output fields:
%
%       isf         either plain false or logical array of input
%                   size with check result (for validity check)

% Version:  v0.7g
% Build:    9033019
% Date:     Mar-30 2009, 7:49 PM CEST
% Author:   Jochen Weber, SCAN Unit, Columbia University, NYC, NY, USA
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% base argument check
if nargin < 1
    error( ...
        'BVQXtools:TooFewArguments', ...
        'At least one input argument is required.' ...
    );
end
chstrict = false;
if nargin > 1 && ...
    numel(varargin{1}) == 1 && ...
   (isnumeric(varargin{1}) || ...
    islogical(varargin{1}))
    if varargin{1}
        chstrict = true;
    end
end

% class check
if isa(htio, 'transio')
    stio = struct(htio);
    isf = logical(osz(stio));
else
    isf = false;
    return;
end

% validation ?
if chstrict

    % make struct and check fields
    sflds = fieldnames(stio);
    if length(sflds) ~= 7 || ...
       ~all(strcmp(sflds, ...
           {'FileName'; ...
            'LittleND'; ...
            'DataType'; ...
            'TypeSize'; ...
            'IOOffset'; ...
            'DataDims'; ...
            'ReadOnly'}))
        isf(:) = false;
        return;
    end
end
